Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Enhance Reporting and Analytics Capabilities #102

Merged
merged 3 commits into from
Nov 9, 2024

Conversation

sanchitc05
Copy link
Contributor

@sanchitc05 sanchitc05 commented Nov 3, 2024

Fixes #95

📊 Add Analytics Endpoints with Role-Based Access Control

Overview

This PR introduces new analytics endpoints to LibraryMan-API, providing valuable insights into library operations. The feature is specifically designed for administrators and librarians to track and analyze library usage patterns.

🚀 New Features

  • Added role-based access control for analytics endpoints
  • Restricted access to ADMIN and LIBRARIAN roles only
  • Enhanced security configuration in WebConfiguration.java

🔒 Security Updates

.requestMatchers("/api/analytics/**").hasAnyRole("ADMIN", "LIBRARIAN")

🎯 Why This Matters

  • Better Insights: Administrators and librarians can now make data-driven decisions
  • Enhanced Security: Role-based access ensures data privacy
  • Operational Efficiency: Easy access to important metrics for authorized personnel

🧪 Testing Checklist
Please verify the following scenarios:

  • Analytics endpoints are accessible with ADMIN role
  • Analytics endpoints are accessible with LIBRARIAN role
  • Analytics endpoints are NOT accessible with USER role
  • Existing endpoints continue to work as expected
  • JWT authentication works correctly with new endpoints

📝 Example Usage

# Access analytics endpoint (requires ADMIN or LIBRARIAN token)
GET /api/analytics/books
Authorization: Bearer <your-jwt-token>

🔍 Review Focus Areas

  1. Security configuration in WebConfiguration.java
  2. Role-based access implementation
  3. Integration with existing JWT authentication
  4. Error handling for unauthorized access

📚 Documentation Updates

  • Updated API documentation to include new analytics endpoints
  • Added role requirements in security documentation
  • Included usage examples for new endpoints

🤝 Testing Instructions

  1. Clone the branch
  2. Run the application
  3. Test with different user roles:
# Login as ADMIN
POST /api/login
{
  "username": "admin",
  "password": "admin_password"
}

# Try accessing analytics
GET /api/analytics/books

🔄 Dependencies

  • No new dependencies added
  • Utilizes existing Spring Security configuration

⚠️ Important Notes

  • This feature requires proper role configuration in the user database
  • Existing ADMIN and LIBRARIAN accounts will automatically have access
  • Remember to update environment variables if necessary

🌟 Future Enhancements

  • Add more detailed analytics endpoints
  • Implement data visualization endpoints
  • Add customizable reporting periods
  • Include export functionality for analytics data

🐛 Known Issues

  • None at this time

📋 Checklist

  • Code follows project style guidelines
  • Added necessary documentation
  • Updated API documentation
  • Added/updated tests
  • All tests passing
  • No new warnings
  • Security review completed

💡 Questions or suggestions? Feel free to comment below!

🙏 Thank you for reviewing this PR. Your feedback is valuable and appreciated!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Thank you @sanchitc05 for your contribution! Your pull request has been submitted successfully, and a maintainer will review it soon. We’re excited to have you on board! Remember to star the repo 🌟 to help us grow, and follow @ajaynegi45 to stay in the loop and increase the visibility of your contributions!

@Guhapriya01
Copy link
Collaborator

error image

It looks like the findByMember_memberId method was removed from the Borrowing Repository. Could you please re-add it?

@sanchitc05
Copy link
Contributor Author

sanchitc05 commented Nov 5, 2024

Oh yeah sure @Guhapriya01

@sanchitc05
Copy link
Contributor Author

@Guhapriya01 please review the changes and feel free to merge pr if everything looks good.

@sanchitc05
Copy link
Contributor Author

@Guhapriya01 I have added Page<Borrowings> findByMember_memberId(int memberId, Pageable pageable); please feel free to merge it with required labels.

@MastanSayyad MastanSayyad merged commit 1ea359d into ajaynegi45:main Nov 9, 2024
1 check passed
@MastanSayyad MastanSayyad added gssoc-ext level2 GirlScript Summer Of Code - 25 points labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext level2 GirlScript Summer Of Code - 25 points
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Enhance Reporting and Analytics Capabilities
3 participants